#include "imgui/custom/Layer.h"

ImGui::Layer::Layer(const std::string &title, ImGuiWindowFlags flag) : m_Title(title), m_Flag(flag)
{

}

void ImGui::Layer::OnDestroy()
{
    
}
bool ImGui::Layer::MenuItem()
{
    if (this->m_Children.size() == 0)
    {
        bool res = ImGui::MenuItem(this->m_Title.c_str(), nullptr, &m_Open);
        return res;
    }
    else
    {

        if (ImGui::BeginMenu(this->m_Title.c_str()), &m_Open)
        {

            for (auto child : m_Children)
            {
                child->MenuItem();
            }
        }
    }
};

void ImGui::Layer::Inst()
{

    if (m_Open)
    {
        if (m_Rendering = ImGui::Begin(m_Title.c_str(), &m_Open, m_Flag))
        {
            m_IsFocused = ImGui::IsWindowFocused();
            m_IsHovered = ImGui::IsWindowHovered();
            ViewFunc();
        }
        ImGui::End();
    }
    for (auto& child : m_Children)
    {
        child->Inst();
    }
}

void ImGui::Layer::Handle()
{
    {
        this->HandleFunc();
    }
    for (auto child : m_Children)
    {
        child->HandleFunc();
    }

}



void ImGui::Layer::ViewFunc()
{
}

void ImGui::Layer::HandleFunc()
{
}
